#include "Main.h"
#include "Window.h"
#include "2DDevice.h"
#include "Select.h"
#include "AstarPathFind.h"

#include "BinaryHeap.h"

#include "QuadRenderer.h"
#include "LineRenderer.h"

#include <windows.h>
#include <stdio.h>
#include "Map.h"
#include "Vis.h"


cMain::cMain()
{
	State = STATE_PATHFIND;
}

void cMain::Init(cWindow * Window, c2DDevice * TwoDDevice,cMap * Map, cSelect* Select, cVis * Vis, cAstarPathFind * AstarPathFind ,cBinaryHeap * BinaryHeap ,cQuadRenderer * QuadRenderer, cLineRenderer * LineRenderer, cPath * Path)
{
this->Window = Window;
this->TwoDDevice=TwoDDevice;
this->Map=Map;
this->Select=Select;
this->Vis=Vis;
this->AstarPathFind=AstarPathFind;
this->BinaryHeap=BinaryHeap;
this->QuadRenderer=QuadRenderer;
this->LineRenderer=LineRenderer;
this->Path=Path;
}


cMain::~cMain()
{


}


void cMain::MainLoop()
{
	
    MSG   msg;
	
    ZeroMemory( &msg, sizeof(msg) );
	//PathFind->FindPath(0,0,6,6);
            while( msg.message!=WM_QUIT )
            {
                if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
                {
                    TranslateMessage( &msg );
                    DispatchMessage( &msg );
                }
                else
                  TwoDDevice->Render();
				//GetCursorPos(&point);
				//Window->CursorPosX = point.x;
				//Window->CursorPosY = point.y;
				//sprintf(Window->text2, "x: %d, y: %d", point.x, point.y);
				//SendMessage(Window->hwndButton3, WM_SETTEXT, 0, (LPARAM)Window->text2);
			//SetWindowText(cWindow::hWndMainFrame,text);
            }
}